package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceOrderSettlement;
import com.ruoyi.zsyh.service.IZsyhServiceOrderSettlementService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工单结算信息Controller
 * 
 * @author yuexl
 * @date 2022-09-09
 */
@Controller
@RequestMapping("/zsyh/serviceOrderSettlement")
public class ZsyhServiceOrderSettlementController extends BaseController
{
    private String prefix = "zsyh/serviceOrderSettlement";

    @Autowired
    private IZsyhServiceOrderSettlementService zsyhServiceOrderSettlementService;

    @RequiresPermissions("zsyh:serviceOrderSettlement:view")
    @GetMapping()
    public String serviceOrderSettlement()
    {
        return prefix + "/serviceOrderSettlement";
    }

    /**
     * 查询工单结算信息列表
     */
    /*@RequiresPermissions("zsyh:serviceOrderSettlement:list")*/
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceOrderSettlement zsyhServiceOrderSettlement)
    {
        startPage();
        List<ZsyhServiceOrderSettlement> list = zsyhServiceOrderSettlementService.selectZsyhServiceOrderSettlementList(zsyhServiceOrderSettlement);
        return getDataTable(list);
    }

    /**
     * 查询工单结算信息列表
     */
    /*@RequiresPermissions("zsyh:serviceOrderSettlement:list")*/
    @PostMapping("/listById")
    @ResponseBody
    public TableDataInfo listById(String id,String feeType)
    {
        ZsyhServiceOrderSettlement zsyhServiceOrderSettlement = new ZsyhServiceOrderSettlement();
        zsyhServiceOrderSettlement.setOrderId(id);
        zsyhServiceOrderSettlement.setFeeType(feeType);
        List<ZsyhServiceOrderSettlement> list = zsyhServiceOrderSettlementService.selectZsyhServiceOrderSettlementList(zsyhServiceOrderSettlement);
        return getDataTable(list);
    }

    /**
     * 导出工单结算信息列表
     */
    @RequiresPermissions("zsyh:serviceOrderSettlement:export")
    @Log(title = "工单结算信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceOrderSettlement zsyhServiceOrderSettlement)
    {
        List<ZsyhServiceOrderSettlement> list = zsyhServiceOrderSettlementService.selectZsyhServiceOrderSettlementList(zsyhServiceOrderSettlement);
        ExcelUtil<ZsyhServiceOrderSettlement> util = new ExcelUtil<ZsyhServiceOrderSettlement>(ZsyhServiceOrderSettlement.class);
        return util.exportExcel(list, "工单结算信息数据");
    }

    /**
     * 新增工单结算信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存工单结算信息
     */
    @RequiresPermissions("zsyh:serviceOrderSettlement:add")
    @Log(title = "工单结算信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceOrderSettlement zsyhServiceOrderSettlement)
    {
        return toAjax(zsyhServiceOrderSettlementService.insertZsyhServiceOrderSettlement(zsyhServiceOrderSettlement));
    }

    /**
     * 修改工单结算信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceOrderSettlement zsyhServiceOrderSettlement = zsyhServiceOrderSettlementService.selectZsyhServiceOrderSettlementById(id);
        mmap.put("zsyhServiceOrderSettlement", zsyhServiceOrderSettlement);
        return prefix + "/edit";
    }

    /**
     * 修改保存工单结算信息
     */
    @RequiresPermissions("zsyh:serviceOrderSettlement:edit")
    @Log(title = "工单结算信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceOrderSettlement zsyhServiceOrderSettlement)
    {
        return toAjax(zsyhServiceOrderSettlementService.updateZsyhServiceOrderSettlement(zsyhServiceOrderSettlement));
    }

    /**
     * 删除工单结算信息
     */
    @RequiresPermissions("zsyh:serviceOrderSettlement:remove")
    @Log(title = "工单结算信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceOrderSettlementService.deleteZsyhServiceOrderSettlementByIds(ids));
    }
}
